From c3e1c194909fb7baf4334ddba5a44c7a6da62bc3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 1 Feb 2016 10:02:04 -0800 Subject: [PATCH] Make tests a little more robust * Remove the XDG_CONFIG_HOME environment variable as we're resetting HOME * Add GIT_CONFIG_NOSYSTEM to encourage git to not read that configuration Closes #2345 --- tests/test_cargo_new.rs | 22 ++++++++-------------- tests/tests.rs | 6 ++++-- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/tests/test_cargo_new.rs b/tests/test_cargo_new.rs index 63868112f..2c97ba9aa 100644 --- a/tests/test_cargo_new.rs +++ b/tests/test_cargo_new.rs @@ -12,12 +12,6 @@ use cargo::util::{process, ProcessBuilder}; fn setup() { } -fn my_process(s: &str) -> ProcessBuilder { - let mut p = process(s); - p.cwd(&paths::root()).env("HOME", &paths::home()); - return p; -} - fn cargo_process(s: &str) -> ProcessBuilder { let mut p = ::cargo_process(); p.arg(s); @@ -188,10 +182,10 @@ test!(finds_author_email { }); test!(finds_author_git { - my_process("git").args(&["config", "--global", "user.name", "bar"]) - .exec().unwrap(); - my_process("git").args(&["config", "--global", "user.email", "baz"]) - .exec().unwrap(); + ::process("git").args(&["config", "--global", "user.name", "bar"]) + .exec().unwrap(); + ::process("git").args(&["config", "--global", "user.email", "baz"]) + .exec().unwrap(); assert_that(cargo_process("new").arg("foo").env("USER", "foo"), execs().with_status(0)); @@ -202,10 +196,10 @@ test!(finds_author_git { }); test!(author_prefers_cargo { - my_process("git").args(&["config", "--global", "user.name", "foo"]) - .exec().unwrap(); - my_process("git").args(&["config", "--global", "user.email", "bar"]) - .exec().unwrap(); + ::process("git").args(&["config", "--global", "user.name", "foo"]) + .exec().unwrap(); + ::process("git").args(&["config", "--global", "user.email", "bar"]) + .exec().unwrap(); let root = paths::root(); fs::create_dir(&root.join(".cargo")).unwrap(); File::create(&root.join(".cargo/config")).unwrap().write_all(br#" diff --git a/tests/tests.rs b/tests/tests.rs index 8eb5f5aa7..a9ec84adc 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -90,8 +90,10 @@ fn process>(t: T) -> cargo::util::ProcessBuilder { p.cwd(&support::paths::root()) .env("HOME", &support::paths::home()) .env_remove("CARGO_HOME") - .env_remove("CARGO_TARGET_DIR") // we assume 'target' - .env_remove("MSYSTEM"); // assume cmd.exe everywhere on windows + .env_remove("XDG_CONFIG_HOME") // see #2345 + .env("GIT_CONFIG_NOSYSTEM", "1") // keep trying to sandbox ourselves + .env_remove("CARGO_TARGET_DIR") // we assume 'target' + .env_remove("MSYSTEM"); // assume cmd.exe everywhere on windows return p } -- 2.30.2